package com.sumainfor.pc.market.controller.directormarket;

import com.sumainfor.common.util.JsonResult;
import com.sumainfor.common.utlis.PageUtils;
import com.sumainfor.common.utlis.Pager;
import com.sumainfor.pc.market.service.DmMediumService;
import com.sumainfor.pc.market.service.RdBankService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @Date 2018年11月7日
 * @Describe 银行
 */
@RestController
@RequestMapping("/directormarket/DmMediumController")
public class DmMediumController implements Serializable {
    @Autowired
    private DmMediumService dmMediumService;
    /**
     * 分页查询中介列表
     */
    @GetMapping("/getTenantList")
    public JsonResult getTenantList(@RequestParam Map<String,Object> params, Pager pager){
        JsonResult result=new JsonResult();
        pager.setPagerNecessary(params, pager);
        PageUtils pageUtils = new PageUtils();
        Integer cout=dmMediumService.getMediumListCount(params);
        if(cout==0){
            return pageUtils.getJsonResult(new ArrayList<Map<String,Object>>(), params,cout);
        }
        List<Map<String,Object>> getCommunityList=dmMediumService.getMediumList(params);
        result=pageUtils.getJsonResult(getCommunityList, params, cout);
        return result;
    }
    /**
     * 新增中介
     */
    @PostMapping("/addMedium")
    public JsonResult addMedium(@RequestBody Map<String,Object>params){
        JsonResult result=new JsonResult();
        int resultsjk=dmMediumService.addMedium(params);
        if (resultsjk>0){
            result.putSuccess("创建成功");
        }else{
            result.putFailed("服务器繁忙");
        }
        return  result;
    }
    /**
     * 分页查询中介列表
     */
    @GetMapping("/getMeIdist")
    public JsonResult getMeIdist(@RequestParam Map<String,Object> params){
        JsonResult result=new JsonResult();
        List<Map<String,Object>> list=dmMediumService.getMeIdist(params);
        if (list!=null){
            result.put(list);
        }else{
            result.putFailed("服务器繁忙");
        }
        return result;
    }
    /**
     * 根据中介的编号查询中介的信息
     */
    @GetMapping("/getMeInfo")
    public JsonResult getMeInfo(@RequestParam Map<String,Object> params){
        JsonResult result=new JsonResult();
        Map<String,Object> map=dmMediumService.getMeInfo(params);
        if (map!=null){
            result.put(map);
        }else{
            result.putFailed("服务器繁忙");
        }
        return result;
    }
    /**
     * 查询某个中介介绍的租客签约次数按月份分组
     */
    @GetMapping("/getMeTentByMonth")
    public JsonResult getMeTentByMonth(@RequestParam Map<String,Object> params){
        return dmMediumService.getMeTentByMonth(params);
    }
    /**
     * 查询中介介绍的租客有签约的年份
     */
    @GetMapping("/getMeMonthList")
    public JsonResult getMeMonthList(@RequestParam Map<String,Object> params){
        return dmMediumService.getMeMonthList(params);
    }

}
